home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection 1998 Fall: Game Toolkit / Disc.iso / Samples / Moofwars 1.02 / Tim's Libraries / Common Stuff.h next >
Encoding:
Text File  |  1996-08-15  |  2.2 KB  |  75 lines  |  [TEXT/CWIE]

  1. // Common Stuff.h is a simple include file that holds a number of standard functions,
  2. // constants, and debugging macros.  Anything that isn't likely to change from program
  3. // to program.
  4.  
  5. #ifndef _COMMONSTUFF_
  6. #define _COMMONSTUFF_
  7.  
  8. #pragma once
  9.  
  10. /*********************************************************************************
  11.     DEBUGGING and ERROR HANDLING MACROS
  12.     
  13.     These macros should be used to create code with proper error handling.  In
  14.     the debugging version of the macros, they dump a string to the debugger before
  15.     dropping into the error handler.
  16.     
  17.     To turn debugging off, set the macro qDebugging to 0 before including Common Stuff.
  18.     
  19.     If an application wants to include special debugging code, the proper way to do this
  20.     is with something like:
  21.     
  22.     #if qDebugging
  23.           // do additional sanity checking here.
  24.     #endif
  25.     
  26.     Note that this should only be additional sanity checking code and not eliminate all error
  27.     checking code.
  28.     
  29. *********************************************************************************/
  30. #define qDebugging 0
  31. #ifndef qDebugging
  32.     #define qDebugging 0
  33. #endif
  34.  
  35. #if qDebugging
  36.     #define SIGNAL_ERROR(msg)        {DebugStr(msg); goto error;}
  37. #else
  38.     #define SIGNAL_ERROR(msg)        {goto error;}
  39. #endif
  40.  
  41. #define FAIL_NIL(y,msg)            if (y == NULL) SIGNAL_ERROR(msg)
  42. #define FAIL_OSERR(y,msg)        if (y != noErr) SIGNAL_ERROR(msg)
  43. #define FAIL_FALSE(y,msg)        if (!y) SIGNAL_ERROR(msg)
  44.     
  45.  
  46. /*********************************************************************************
  47.     QUICKDRAW
  48.     
  49.     This includes a standard set of functions and color constants to use in apps
  50.     that use quickdraw.  As written, this will only compile for C++, although the
  51.     functions could be recast as macros.
  52.     
  53. *********************************************************************************/
  54.  
  55. #include <Quickdraw.h>
  56.  
  57. const RGBColor kWhite = {0xFFFF, 0xFFFF, 0xFFFF};
  58. const RGBColor kBlack = {0x0000, 0x0000, 0x0000};
  59. const RGBColor kDarkBlue = {0x0000,0x0000,0x7000};
  60. const RGBColor kLtGrey = {0xC000,0xC000,0xC000};
  61. const RGBColor kMediumGrey = {0x7FFF,0x7FFF,0x7FFF};
  62.  
  63. inline short RectWidth (const Rect& r) {
  64.     return (r.right-r.left);
  65.     }
  66.  
  67. inline short RectHeight (const Rect& r) {
  68.     return (r.bottom - r.top);
  69.     }
  70.  
  71. #endif /* _COMMONSTUFF_ */
  72.  
  73.     
  74.  
  75.